import Vue from "vue";
import App from "../app/App.vue";
import Vuex from "vuex";
import store from "../app/store.js";
import "babel-polyfill";
import Router from "vue-router";
import RouterPath from "./routerPath.js";
var routerPath = new RouterPath();
Vue.use(Router);
Vue.use(Vuex);
Vue.config.productionTip = false; // Vue.config.silent = true; Vue.config.devtools = true;


import api from "../../api/api";
import config from "./config";
import AppCache from "../app/app";
import Request from "../request.js";
import Demand from "../demand.js";
import ParkUtil from "../utils/parkUtil";
let appCache = new AppCache();
api.getApp = () => appCache;
api.request = new Request(config);
api.demand = new Demand(config);

// 注册组件
import component from "../app/component.js";
Vue.use(component);

var router = new Router({
    // mode: "history",
    // base: process.env.BASE_URL,
    routes: routerPath.getRouterArray()
});
router.onError(error => {
    if (error.message.match(/Loading chunk (\d)+ failed/g)) {
        router.replace(router.history.pending.fullPath);
    }
});
// 初始化Vue
new Vue({
    router: router,
    store: new Vuex.Store(store),
    render: h => h(App),
    beforeCreate: function() {
        Vue.instance = this;
    }
}).$mount("#app");